<?
include('adodb/adodb-exceptions.inc.php'); 
require ("comun/ini.php");
if(isset($_POST['JsonEnv'])){
	$JsonRec = new Services_JSON();
	$JsonEnv = new Services_JSON();
	$JsonRec=$JsonRec->decode(str_replace("\\","",$_POST['JsonEnv']));
	try {
		$q = "SELECT genera_factura_pago AS id_factura FROM genera_factura_pago($JsonRec->ID)";
		$r = $conn->Execute($q);
		$i=0;
		if(!$r->EOF){
			$Transfer[$i]['ID'] = $r->fields['id_factura'];
			$Transfer[$i]['E'] = "OK";
		} else {
			$Transfer[$i]['ID'] = "-1";
			$Transfer[$i]['E'] = "ERROR";
		}
		if(is_array($Transfer)){
			echo $JsonEnv->encode($Transfer);
		}else{
			echo false;
		}
	}catch( ADODB_Exception $e ){
		//	echo ERROR_CATCH_GENERICO;
		echo false;
	}
} 
?>